package GUCI;

import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.File;
import java.io.IOException;

public class recive {    
    public static void Poem(String input,String word) {
    	 int sign = 0; 
    	 int all = 0; 
    	//统计word出现次数
    		 for(int i =0; i<input.length(); i++) {
            System.out.print(input.charAt(i));
            if(input.charAt(i) == word.charAt(0)) {
                all++;
            }
         // 0，输出逗号，1，输出句号+换行
            if(i>0 && i%7==6) {
                if(sign == 0) {
                    System.out.print(",");
                    sign = 1;
                } 
                else {
                    System.out.print("。\n");
                    sign = 0;
                }
            }
        }
   
        System.out.println("\n"+word+"的出现次数为:"+all);
      
    }
    
public static void main(String[] args) throws Exception {
    	System.out.println("——————欢迎使用诗词修复——————");
    	System.out.println("请输入您要恢复的诗词：");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String it = br.readLine();
        System.out.println("请输入您要统计的字：");
        String wd = br.readLine();
        Poem(it,wd);//调用上方poem方法
        
        /*
        String path = "D:\\test\\test.txt";
        String word = "试试";
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path,true)));
        out.write(word+"\r\n");
        out.close();*/
    }
     

}
